Imports System.ComponentModel
Imports System.Globalization

' Implementation thanks to:
'  http://stackoverflow.com/questions/964912/collection-editor-within-a-user-control-at-design-time
'  http://www.codeproject.com/KB/cs/dzcollectioneditor.aspx

''' <summary>
''' A configuration for a given unit to use in the NumericTextBox.
''' </summary>
''' <remarks></remarks>
<System.ComponentModel.DesignTimeVisible(False), _
 Category("Unit Configuration")> _
Public Class UnitConfiguration
   Inherits Component

#Region "Private Fields"

   Private mUnit As String
   Private mConversionFactor As Nullable(Of Decimal)
   Private mDecimalPlaces As Integer
   Private mLocation As UnitLocation

#End Region

#Region "Public Properties"

   ''' <summary>
   ''' The textual representation of the unit (like mm, kg, $, ...).
   ''' </summary>
   ''' <value></value>
   ''' <returns></returns>
   ''' <remarks></remarks>
   <Category("Data"), _
    DefaultValue("pcs"), _
    Description("The textual representation of the unit (like mm, kg, $, ...).")> _
   Public Property Unit() As String
      Get
         Return Me.mUnit
      End Get
      Set(ByVal value As String)
         Me.mUnit = value
      End Set
   End Property

   ''' <summary>
   ''' The factor by which to multiply a value in this unit to convert it to the base unit. Leave empty to use no conversion.
   ''' </summary>
   ''' <value></value>
   ''' <returns></returns>
   ''' <remarks></remarks>
   <Category("Data"), _
    Description("The factor by which to multiply a value in this unit to convert it to the base unit. Leave empty to use no conversion.")> _
   Public Property ConversionFactor() As Nullable(Of Decimal)
      Get
         Return Me.mConversionFactor
      End Get
      Set(ByVal value As Nullable(Of Decimal))
         Me.mConversionFactor = value
      End Set
   End Property

   ''' <summary>
   ''' Indicates the number of decimal places to display (this overrides the default of the NumericTextBox).
   ''' </summary>
   ''' <value></value>
   ''' <returns></returns>
   ''' <remarks></remarks>
   <Category("Data"), _
    DefaultValue(0), _
    Description("Indicates the number of decimal places to display (this overrides the default of the NumericTextBox).")> _
   Public Property DecimalPlaces() As Integer
      Get
         Return Me.mDecimalPlaces
      End Get
      Set(ByVal value As Integer)
         Me.mDecimalPlaces = value
      End Set
   End Property

   ''' <summary>
   ''' Indicates whether the unit is displayed before or after the value.
   ''' </summary>
   ''' <value></value>
   ''' <returns></returns>
   ''' <remarks></remarks>
   <Category("Data"), _
    DefaultValue(UnitLocation.After), _
    Description("Indicates whether the unit is displayed before or after the value.")> _
   Public Property Location() As UnitLocation
      Get
         Return Me.mLocation
      End Get
      Set(ByVal value As UnitLocation)
         Me.mLocation = value
      End Set
   End Property

#End Region

End Class